/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_compagnie")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvCompagnie.findAll", query = "SELECT c FROM CvCompagnie c"),
    @NamedQuery(name = "CvCompagnie.findByIdcompagnie", query = "SELECT c FROM CvCompagnie c WHERE c.idcompagnie = :idcompagnie"),
    @NamedQuery(name = "CvCompagnie.findByNomcompagnie", query = "SELECT c FROM CvCompagnie c WHERE c.nomcompagnie = :nomcompagnie"),
    @NamedQuery(name = "CvCompagnie.findByEtat", query = "SELECT c FROM CvCompagnie c WHERE c.active = :active")})
public class CvCompagnie implements Serializable {
    @Column(name = "active")
    private boolean active;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idcompagnie")
    private Integer idcompagnie;
    @Column(name = "nomcompagnie")
    private String nomcompagnie;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcompagnie", fetch = FetchType.EAGER)
    private List<CvTravail> cvTravailList;

    public CvCompagnie() {
    }

    public CvCompagnie(Integer idcompagnie) {
        this.idcompagnie = idcompagnie;
    }

    public Integer getIdcompagnie() {
        return idcompagnie;
    }

    public void setIdcompagnie(Integer idcompagnie) {
        this.idcompagnie = idcompagnie;
    }

    public String getNomcompagnie() {
        return nomcompagnie;
    }

    public void setNomcompagnie(String nomcompagnie) {
        this.nomcompagnie = nomcompagnie;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvTravail> getCvTravailList() {
        return cvTravailList;
    }

    public void setCvTravailList(List<CvTravail> cvTravailList) {
        this.cvTravailList = cvTravailList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcompagnie != null ? idcompagnie.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvCompagnie)) {
            return false;
        }
        CvCompagnie other = (CvCompagnie) object;
        if ((this.idcompagnie == null && other.idcompagnie != null) || (this.idcompagnie != null && !this.idcompagnie.equals(other.idcompagnie))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvCompagnie[ idcompagnie=" + idcompagnie + " ]";
    }
    
    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }
    
}
